import React from 'react';
import {BrowserRouter as Router, useLocation} from 'react-router-dom';

import Layouts from './Layouts';
import Invite from './views/Invite';

import {PublicDataProvider} from '@src/store/PublicData/Provider';

import './App.less';

function App() {

    return (
        <div className="App">
            <Router>
                <PublicDataProvider>
                    <Main />
                </PublicDataProvider>
            </Router>
        </div>
    );
}

const Main = () => {
    const location = useLocation();

    // 检查当前路径是否是 "/invite"
    const isInvitePage = location.pathname === '/invite';

    return (
        <>
            {!isInvitePage && <Layouts />} {/* 如果不是 /invite，渲染 Layouts */}
            {isInvitePage && <Invite />} {/* 如果是 /invite，渲染 Invite */}
        </>
    );
};

export default App;
